// pages/login/newword.js
const common = require('../../public.js')
Page({

    /**
     * 页面的初始数据
     */
    data: {
        password:'',
        sms:'',
        telephone:""
    },
    // 密码输入
    click_password(event){
        this.setData({
            password:event.detail 
        })    
    },
    click_passlogin(){
        var that = this
        if (that.data.password == '') {
            wx.showToast({
              title: '密码不能为空',
              icon: 'none'
            })
            return
          }
          const tempJson ={
            telephone:that.data.telephone,
            msgCode:that.data.sms,
            password:this.data.password
          }

          common.wxRequest("/user/password/forget", 
          "post", 
          tempJson, 
          'application/x-www-form-urlencoded',
           function (res) {
            wx.showToast({
              title: res.msg,
              icon:"none"
            })
             if(res.status==200){
               wx.navigateTo({
                 url: '/pages/login/password',
               })
             }else{
                 wx.showToast({
                   title: res.msg,
                   icon:"none"
                 })
             }
            })  

    },
    onLoad: function (options) {
     console.log(options)
     this.setData({
         sms:options.sms ? options.sms :'',
         telephone:options.telephone ? options.telephone :''
     })
    },
})